/*
Copyright (C) 2011 Ing. Marek Hubal

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#pragma once

#define BITMAP2_IMAGE_ERROR_OPEN_FILE -1
#define BITMAP2_IMAGE_ERROR_READ_FILE -2
#define BITMAP2_IMAGE_ERROR_FILE_HEADER_CORRUPTED -2
#define BITMAP2_IMAGE_ERROR_UNSUPORTED_BITS_PER_PIXEL -3
#define BITMAP2_IMAGE_ERROR_UNSUPORTED_COMPRESSION -4
#define BITMAP2_IMAGE_ERROR_CREATE_FILE -5
#define BITMAP2_IMAGE_ERROR_WRITE_FILE -6

#define COLORREF UINT32

// ................................................................................................
// Trieda IBitmap2
// ................................................................................................
class IBitmap2 {
public:
	INT32 Width, Height; // Rozmery
	COLORREF Pallete[2]; // Farby
	PBYTE RawData; // Data obrazku
public:
	INT32 RowSize; // Velkost jedneho riadku v bajtoch
	INT32 RawDataSize; // Velkost raw dat
	INT32 Count0, Count1; // Pocet nulovych a jednotkovych bitov
	INT32 ValidRowSize; // Platna dlzka riadku
	BYTE LastRowByteMask; // Mask posledneho platneho bajtu v riadku
	PBYTE *Rows; // Zaciatky riadkov
public:
	IBitmap2(void); // Konstruktor
	~IBitmap2(void); // Destruktor
public:
	void __fastcall Clear(void); // Uvolnenie objektu z pamate
	bool __fastcall GetPixel(INT32 pX, INT32 pY); // Ziskanie hodnoty pixela na zadanej pozicii
	void __fastcall SetPixel(INT32 pX, INT32 pY, bool pValue); // Nastavenie hodnoty pixela na zadanej pozicii
public:
	INT32 __fastcall LoadFromBMP(CONST_PCHAR pFileName); // Nacitanie obsahu z BMP suboru
	INT32 __fastcall SaveToBMP(CONST_PCHAR pFileName); // Ulozenie obsahu do BMP suboru
	IBitmap2* __fastcall Clone(void); // Vytvorenie kopie aktualneho obrazku
	void __fastcall Create(INT32 pWidth, INT32 pHeight); // Vytvorenie prazdneho obrazku
};
// ................................................................................................
